﻿using System;
using System.IO;
using System.Security.AccessControl;
using System.Text;
using Rhino.Commons;

namespace FileUtils {
	/// <summary>
	/// Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of innerImplStream objects.
	/// </summary>
	public static class FileEx {
		private static IFile innerImpl {
			get { return IoC.Resolve<IFile>(); }
		}

		public static void AppendAllText(string path, string contents, Encoding encoding) {
			innerImpl.AppendAllText(path, contents, encoding);
		}

		public static void AppendAllText(string path, string contents) {
			innerImpl.AppendAllText(path, contents);
		}

		public static void AppendText(string path) {
			innerImpl.AppendText(path);
		}

		public static void Copy(string sourceFilename, string destFilename, bool overwrite) {
			innerImpl.Copy(sourceFilename, destFilename, overwrite);
		}

		public static void Copy(string sourceFilename, string destFilename) {
			innerImpl.Copy(sourceFilename, destFilename);
		}

		public static FileStream Create(string path, int bufferSize, FileOptions options, FileSecurity security) {
			return innerImpl.Create(path, bufferSize, options, security);
		}

		public static FileStream Create(string path, int bufferSize, FileOptions options) {
			return innerImpl.Create(path, bufferSize, options);
		}

		public static FileStream Create(string path, int bufferSize) {
			return innerImpl.Create(path, bufferSize);
		}

		public static FileStream Create(string path) {
			return innerImpl.Create(path);
		}

		public static StreamWriter CreateText(string path) {
			return innerImpl.CreateText(path);
		}

		public static void Decrypt(string path) {
			innerImpl.Decrypt(path);
		}

		public static void Delete(string path) {
			innerImpl.Delete(path);
		}

		public static void Encrypt(string path) {
			innerImpl.Encrypt(path);
		}

		public static bool Exists(string path) {
			return innerImpl.Exists(path);
		}

		public static FileSecurity GetAccessControl(string path, AccessControlSections includeSections) {
			return innerImpl.GetAccessControl(path, includeSections);
		}

		public static FileSecurity GetAccessControl(string path) {
			return innerImpl.GetAccessControl(path);
		}

		public static FileAttributes GetAttributes(string path) {
			return innerImpl.GetAttributes(path);
		}

		public static DateTime GetCreationTime(string path) {
			return innerImpl.GetCreationTime(path);
		}

		public static DateTime GetCreationTimeUtc(string path) {
			return innerImpl.GetCreationTimeUtc(path);
		}

		public static DateTime GetLastAccessTime(string path) {
			return innerImpl.GetLastAccessTime(path);
		}

		public static DateTime GetLastAccessTimeUtc(string path) {
			return innerImpl.GetLastAccessTimeUtc(path);
		}

		public static DateTime GetLastWriteTime(string path) {
			return innerImpl.GetLastWriteTime(path);
		}

		public static DateTime GetLastWriteTimeUtc(string path) {
			return innerImpl.GetLastWriteTimeUtc(path);
		}

		public static void Move(string sourceFilename, string destFilename) {
			innerImpl.Move(sourceFilename, destFilename);
		}

		public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share) {
			return innerImpl.Open(path, mode, access, share);
		}

		public static FileStream Open(string path, FileMode mode, FileAccess access) {
			return innerImpl.Open(path, mode, access);
		}

		public static FileStream Open(string path, FileMode mode) {
			return innerImpl.Open(path, mode);
		}

		public static FileStream OpenRead(string path) {
			return innerImpl.OpenRead(path);
		}

		public static StreamReader OpenText(string path) {
			return innerImpl.OpenText(path);
		}

		public static FileStream OpenWrite(string path) {
			return innerImpl.OpenWrite(path);
		}

		public static byte[] ReadAllBytes(string path) {
			return innerImpl.ReadAllBytes(path);
		}

		public static string[] ReadAllLines(string path, Encoding encoding) {
			return innerImpl.ReadAllLines(path, encoding);
		}

		public static string[] ReadAllLines(string path) {
			return innerImpl.ReadAllLines(path);
		}

		public static string ReadAllText(string path, Encoding encoding) {
			return innerImpl.ReadAllText(path, encoding);
		}

		public static string ReadAllText(string path) {
			return innerImpl.ReadAllText(path);
		}

		public static void Replace(string sourceFilename, string destFilename, string destBackupFilename, bool ignoreMetadataErrors) {
			innerImpl.Replace(sourceFilename, destFilename, destBackupFilename, ignoreMetadataErrors);
		}

		public static void Replace(string sourceFilename, string destFilename, string destBackupFilename) {
			innerImpl.Replace(sourceFilename, destFilename, destBackupFilename);
		}

		public static void SetAccessControl(string path, FileSecurity security) {
			innerImpl.SetAccessControl(path, security);
		}

		public static void SetAttributes(string path, FileAttributes attributes) {
			innerImpl.SetAttributes(path, attributes);
		}

		public static void SetCreationTime(string path, DateTime creationTime) {
			innerImpl.SetCreationTime(path, creationTime);
		}

		public static void SetCreationTimeUtc(string path, DateTime creationTime) {
			innerImpl.SetCreationTimeUtc(path, creationTime);
		}

		public static void SetLastAccessTime(string path, DateTime creationTime) {
			innerImpl.SetLastAccessTime(path, creationTime);
		}

		public static void SetLastAccessTimeUtc(string path, DateTime creationTime) {
			innerImpl.SetLastAccessTimeUtc(path, creationTime);
		}

		public static void SetLastWriteTime(string path, DateTime creationTime) {
			innerImpl.SetLastWriteTime(path, creationTime);
		}

		public static void SetLastWriteTimeUtc(string path, DateTime creationTime) {
			innerImpl.SetLastWriteTimeUtc(path, creationTime);
		}

		public static void WriteAllBytes(string path, byte[] bytes) {
			innerImpl.WriteAllBytes(path, bytes);
		}

		public static void WriteAllLines(string path, string[] contents, Encoding encoding) {
			innerImpl.WriteAllLines(path, contents, encoding);
		}

		public static void WriteAllLines(string path, string[] contents) {
			innerImpl.WriteAllLines(path, contents);
		}

		public static void WriteAllText(string path, string contents, Encoding encoding) {
			innerImpl.WriteAllText(path, contents, encoding);
		}

		public static void WriteAllText(string path, string contents) {
			innerImpl.WriteAllText(path, contents);
		}
	}
}